﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BO;
using BO.Security;

namespace UI.Security
{
    public partial class LogonForm : Form
    {
        public LogonForm()
        {
            InitializeComponent();
            this.MaximizeBox = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.AcceptButton = btnLogon;
            
            txtPassword.TextBox.UseSystemPasswordChar = true;
            this.CenterToScreen();
#if DEBUG
             txtUserName.TextBox.Text="SUPERUSER";
             txtPassword.TextBox.Text="455754947";
             btnLogon.Focus();
#endif
        }

        private void btnLogon_Click(object sender, EventArgs e)
        {
            var userName = txtUserName.TextBox.Text;
            var userPwd = txtPassword.TextBox.Text;
            BOPrincipal.Logout();
            if (BOPrincipal.Login(userName, userPwd))
            {
                DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或密码错误.");
            }
          
        }
    }
}
